package org.agile2soft.nexoma.core.entities;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "ACCESS")
@SuppressWarnings({"serial"})
public class Access implements java.io.Serializable {

    private AccessId id;
    private String userName;
    private String userLogin;
    private String documentNumber;

    public String toString() {
        return String.format("[Access : %s, %s, %s, %s]",id,userName,userLogin,documentNumber);
    }
    public Access() {
    }

    public Access(AccessId id, String userName,
            String documentNumber) {
        this.id = id;
        this.userName = userName;
        this.documentNumber = documentNumber;
    }

    public Access(AccessId id, String username,
            String userLogin, String documentNumber) {
        this.id = id;
        this.userName = username;
        this.userLogin = userLogin;
        this.documentNumber = documentNumber;
    }

    @EmbeddedId
    @AttributeOverrides( {
            @AttributeOverride(name = "profile", column = @Column(name = "ACC_PROFILE", nullable = false, length = 100)),
            @AttributeOverride(name = "remoteLocate", column = @Column(name = "ACC_REMOTE_LOCATE", nullable = false, length = 2)),
            @AttributeOverride(name = "remoteHost", column = @Column(name = "ACC_REMOTE_HOST", nullable = false, length = 150)),
            @AttributeOverride(name = "remoteAddress", column = @Column(name = "ACC_REMOTE_ADDRESS", nullable = false, length = 150)),
            @AttributeOverride(name = "outDate", column = @Column(name = "ACC_OUT_DATE", nullable = false, length = 19)),
            @AttributeOverride(name = "userAgent", column = @Column(name = "ACC_USER_AGENT", nullable = false, length = 150)),
            @AttributeOverride(name = "date", column = @Column(name = "ACC_DATE", nullable = false, length = 19)) })
    public AccessId getId() {
        return this.id;
    }

    public void setId(AccessId id) {
        this.id = id;
    }

    @Column(name = "ACC_USER_NAME", nullable = false, length = 100)
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "ACC_USER_LOGIN", length = 15)
    public String getUserLogin() {
        return this.userLogin;
    }

    public void setUserLogin(String userLogin) {
        this.userLogin = userLogin;
    }

    @Column(name = "ACC_DOCUMENT_NUMBER", nullable = false, length = 25)
    public String getDocumentNumber() {
        return this.documentNumber;
    }

    public void setDocumentNumber(String documentNumber) {
        this.documentNumber = documentNumber;
    }

}
